from .database.sql import Mysql
from .models import *


class WeatherPipeline(object):
    session = Mysql.get_session()

    def process_item(self, item, spider):
        weather = item['weather']
        self.session.query(City.id == weather.city_code).update({City.status: 1})
        self.session.merge(weather)
        self.session.commit()
        return item
